#!/usr/bin/env python

""" An example of how to use the event management system by itself. """

from sbak import video, event

video.init()
event.init()

eqm = event.SysEventQueueManager()

def handle_keydown(hk):
    print "Key pressed. Code:", hk.event.key

def handle_keyup(hk):
    print "Key released. Code:", hk.event.key

def handle_quit(hk):
    global quit
    print "Quitting..."
    quit = True

eqm.hook(handle_keydown, "keydown")
eqm.hook(handle_keyup, "keyup")
eqm.hook(handle_quit, "keydown", key = "escape")
eqm.hook(handle_quit, "quit")

SCREENRES = (640, 480)
screen = video.set_mode(SCREENRES)

quit = False
while not quit:
    eqm.dispatch()